import {request, handleError} from "@/api/request";

const BASE_URL = "http://127.0.0.1:8088";

/**
 * 发送留言
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const addMessage = async (val) => {
    try {
        const res = await request.post(BASE_URL + '/message/add_message', val)
        return res
    } catch (err) {
        handleError(err)
    }
}


/**
 * 查看留言
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export const getMessage = async (to_user_id, type) => {
    try {
        const res = await request.get(BASE_URL + `/message/get_message?to_user_id=${to_user_id}&type=${type}`)
        return res
    } catch (err) {
        handleError(err)
    }
}
